<template>
  <div id="app">
    <el-form ref="statics" :model="statics" label-width="80px" :rules="addStatics">
      <h1>工程设计变更申请单</h1>
      <el-form-item label="施工单位" class="head">
        <el-input v-model="statics.construction" disabled></el-input>
      </el-form-item>
      <el-form-item label="编号" class="head">
        <el-input v-model="statics.number" disabled></el-input>
      </el-form-item>
      <el-form-item label="工程名称">
        <el-input v-model="statics.name" style="width:680px" disabled></el-input>
      </el-form-item>
      <el-form-item label="变更部位">
        <el-input type="textarea" v-model="statics.change_parts" style="width:680px" disabled></el-input>
      </el-form-item>
      <el-form-item label="变更内容">
        <el-input type="textarea" v-model="statics.change_content" style="width:680px" disabled></el-input>
      </el-form-item>
      <el-form-item label="申请方">
         <el-select v-model="statics.apply" placeholder="请选择您的身份" style="width:240px" disabled>
          <el-option label="设计方" value="designer"></el-option>
          <el-option label="施工方" value="builder"></el-option>
          <el-option label="监理" value="watcher"></el-option>
          <el-option label="业主" value="boss"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请日期">
        <el-col :span="8">
          <el-date-picker type="date" placeholder="选择日期" v-model="statics.date1" disabled style="width: 100%;"></el-date-picker> 
        </el-col> 
        <el-col class="line" :span="1" :offset="1">-</el-col>
        <el-col :span="8">
          <el-time-picker placeholder="选择时间" v-model="statics.date2" disabled style="width: 100%;"></el-time-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="监理意见" prop="watcher_suggestions">
        <el-input type="textarea" v-model="statics.watcher_suggestions" disabled style="width:680px"></el-input>
      </el-form-item>
      <el-form-item label="监理姓名" prop="watcher_name">
        <el-input v-model="statics.watcher_name" style="width:240px" disabled></el-input>
      </el-form-item>
      <el-form-item label="业主意见" prop="boss_suggestions">
        <el-input type="textarea" v-model="statics.boss_suggestions" style="width:680px" disabled></el-input>
      </el-form-item>
      <el-form-item label="业主姓名" prop="boss_name">
        <el-input v-model="statics.boss_name" style="width:240px" disabled></el-input>
      </el-form-item>
      <el-form-item label="设计方意见" prop="designer_suggestions">
        <el-input type="textarea" v-model="statics.designer_suggestions" style="width:680px"></el-input>
      </el-form-item>
      <el-form-item label="设计方负责人" prop="designer_name">
        <el-input v-model="statics.designer_name" style="width:240px"></el-input>
      </el-form-item>
      <el-form-item>
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :file-list="fileList"
          :on-error = "uploadsuccess"
          list-type="picture">
          <el-button size="small" type="primary">上传单位盖章</el-button>
          &nbsp;&nbsp;&nbsp;<span slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</span>
        </el-upload>
      </el-form-item>
      <!-- <el-form-item label="文件上传   :">
          <el-upload
            class="upload-demo"
            ref="upload"
            action="#"
            :limit="3"
            :http-request="uploadOk"
            :auto-upload="true">
            选取文件
          </el-upload>
      </el-form-item> -->
      <el-form-item>
        <el-button @click.native="exmain" style="width: 100px;" type="primary">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data(){
    return {
      statics:{
        construction: '',
        number: '',
        name: '',
        change_parts: '',
        change_content: '',
        apply: '',
        date1: '',
        date2: '',
        status:0,
        watcher_suggestions: '',
        watcher_name: '',
        boss_suggestions: '',
        boss_name: '',
        designer_suggestions: '',
        designer_name: '',
      },
      addStatics: {
          designer_suggestions: [{ required: true, message: '设计方意见不能为空!', trigger: 'blur' },],
          designer_name: [{ required: true, message: '设计方负责人姓名不能为空!', trigger: 'blur' },],
        },
      fileList:[]
    }
  },
  methods:{
    getInfomation(){
      var obj = JSON.parse(sessionStorage.getItem("application"));
      if(obj.status == 2){
        this.statics = JSON.parse(sessionStorage.getItem("application"));
      }
    },
    exmain(){
      if(this.statics.status == 2){
        this.statics.status = 3;
        sessionStorage.setItem("application", JSON.stringify(this.statics));
        this.$message({
            message: '审批成功',
            type: 'success',
            center: true
        });
      }
    },
    // 虚伪的成功调用
    uploadsuccess(){
      console.log("success");
      this.$message({
        message: '上传成功',
        type: 'success',
        center: true
      });
    }
  },
  mounted(){
    this.getInfomation();
  }
}
</script>

<style lang="less" scoped>
#app{
  height: auto;
}
.el-form {
  width: 800px;
  height: auto;
  margin: 0 auto;
  border: 1px dashed rgba(0, 50, 100, 0.8);
  position: relative;
  h1{
    text-align: center;
  }
  .head{
    .el-input {
      width: 300px;
    }
    display: inline-block;
  }
}
.el-upload--text{
  width: 419px;
  height: 36px;
}
</style>